import createStore from '@/hooks/state-link';

export type PageInfo = {
  title: string;
  desc?: string;
  js?: string;
  css?: string;
};

const useStore = createStore<PageInfo>({ title: '' });

export function usePageInfoStore() {
  const [info, setInfo] = useStore();

  function reset(info: PageInfo) {
    setInfo(info);
  }

  function update(data: PageInfo) {
    setInfo({ ...info, ...data });
  }

  return {
    reset,
    update,
    pageInfo: info,
  };
}
